home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / misc / equation.sty (.txt) < prev    next >
LaTeX Document  |  1989-08-01  |  10KB  |  212 lines

  1. %------------------------------------------------------------------------
  2. % This is equations.sty (August 1988).  Written by
  3. %   Charles Karney
  4. %   Plasma Physics Laboratory   Phone:   +1 609 243 2607
  5. %   Princeton University        MFEnet:  Karney@PPC.MFEnet
  6. %   PO Box 451                  ARPAnet: Karney%PPC.MFEnet@NMFECC.ARPA
  7. %   Princeton, NJ 08543-0451    Bitnet:  Karney%PPC.MFEnet@ANLVMS.Bitnet
  8. % with some ideas and macros borrowed from John Hobby and Stephen Gildea.
  9. % --------------------USER DOCUMENTATION--------------------
  10. % Use this as a style option, e.g.,
  11. %     \documentstyle[equations]{article}
  12. % These probably don't work in conjunction with the leqno option.
  13. % This implements the following:
  14. % (1) \yesnumber turns on an equation number in an eqnarray* environment
  15. % (just as \nonumber turns it off in an eqnarray environment).  E.g.,
  16. %     \begin{eqnarray*}
  17. %        a &=& b \\
  18. %          & & + c \\
  19. %          & & + d \\
  20. %          & & + e \\
  21. %          & & + f \\
  22. %          & & + g \yesnumber
  23. %     \end{eqnarray*}
  24. % (2) The eqalign environment is just like Plain TeX's \eqalign.  E.g.,
  25. %     \begin{equation}
  26. %           \begin{eqalign}
  27. %              a &= b, \\
  28. %              c &= d.
  29. %           \end{eqalign}
  30. %     \end{equation}
  31. % Note that \begin{equation} \end{equation} or equivalent is needed.
  32. % (3) The eqalignno environment is just like Plain TeX's \eqalignno.  E.g.,
  33. %     \begin{eqalignno}
  34. %        a &= b, \label{foo}\\
  35. %        c &= d. \label{bar}
  36. %     \end{eqalignno}
  37. % Note the absence of \begin{equation} \end{equation}.  \nonumber can be used
  38. % to suppress the equation number.  eqalignno* is the same except that the
  39. % equation numbers are suppressed (unless a \yesnumber appears).
  40. % (4) The eqaligntwo environment is a two-equation per line equivalent of
  41. % eqalignno.  E.g.,
  42. %     \begin{eqaligntwo}
  43. %        a &= b, & x &= y, \label{foo} \\
  44. %        c &= d, & z &= w. \label{bar}
  45. %     \end{eqalign}
  46. % eqaligntwo* is defined similarly.
  47. % (5) The cases environment is just like Plain TeX's \cases.  E.g.,
  48. %     \begin{equation}
  49. %        u(x) =
  50. %           \begin{cases}
  51. %             0, & for $x < 0$,
  52. %             1, & for $x \ge 0$.
  53. %           \end{cases}
  54. %     \end{equation}
  55. % Note the first column is treated as math, the second column as text.
  56. % (6) I've borrowed John Hobby's modifications to the eqnarray environment
  57. % (to fix up the spacing around the operator), and to the \big, \bigg, etc.
  58. % operators (to make them scale with the point size).
  59. % (7) I've borrowed Stephen Gildea's subequations environment, and fixed it
  60. % so that it ignores spaces after the environment and so that you can refer
  61. % both to the overall set of equations and to individual subequations.  E.g.,
  62. %     \begin{subequations} \label{foo}
  63. %       \begin{eqalignno}
  64. %          a &= b, \label{foo-a} \\
  65. %          c &= d, \label{foo-b}
  66. %       \end{eqalignno}
  67. %       text text text text ...
  68. %       \begin{equation}
  69. %          e = f. \label{foo-c}
  70. %       \end{equation}
  71. %     \end{subequations}
  72. % Now \ref{foo}, \ref{foo-a}, \ref{foo-b}, \ref{foo-c}, produce 1, 1a, 1b,
  73. % 1c.
  74. % --------------------END OF USER DOCUMENTATION--------------------
  75. \typeout{Document Substyle `EQUATION', modified by MPI, Version 1.0, 09.03.89}
  76. % Fix up eqnarray* so that \yesnumber and \nonumber do the obvious things
  77. \newif\if@defeqnsw \@defeqnswtrue
  78. % This is John Hobby's (hobby@research.att.com) version to fix up the spacing.
  79. \def\eqnarray{\stepcounter{equation}\let\@currentlabel=\theequation
  80. \if@defeqnsw\global\@eqnswtrue\else\global\@eqnswfalse\fi
  81. %\global\@eqnswtrue       inactivated march 89 G. Kruljac
  82. \tabskip\@centering\let\\=\@eqncr
  83. $$\halign to \displaywidth\bgroup\hfil\global\@eqcnt\z@
  84.   $\displaystyle\tabskip\z@{##}$&\global\@eqcnt\@ne
  85.   \hfil$\displaystyle{{}##{}}$\hfil
  86.   &\global\@eqcnt\tw@ $\displaystyle{##}$\hfil
  87.   \tabskip\@centering&\llap{##}\tabskip\z@\cr}
  88. % Here's the eqnarray* environment:
  89. %\let\@seqncr=\@eqncr
  90. \@namedef{eqnarray*}{\@defeqnswfalse\eqnarray}
  91. \@namedef{endeqnarray*}{\endeqnarray}
  92. \def\yesnumber{\global\@eqnswtrue}
  93. \def\@@eqncr{\let\@tempa\relax\global\advance\@eqcnt by \@ne
  94.     \ifcase\@eqcnt \def\@tempa{& & & &}\or \def\@tempa{& & &}\or
  95.      \def\@tempa{& &}\or \def\@tempa{&}\else\fi
  96.      \@tempa \if@eqnsw\@eqnnum\stepcounter{equation}\fi
  97.      \if@defeqnsw\global\@eqnswtrue\else\global\@eqnswfalse\fi
  98.      \global\@eqcnt\z@\cr}
  99. % Several formulas like \eqalign (to go inside \begin{equation}
  100. % \end{equation} or $$ $$.
  101. \def\@eqnacr{{\ifnum0=`}\fi\@ifstar{\@yeqnacr}{\@yeqnacr}}
  102. \def\@yeqnacr{\@ifnextchar [{\@xeqnacr}{\@xeqnacr[\z@]}}
  103. \def\@xeqnacr[#1]{\ifnum0=`{\fi}\cr \noalign{\vskip\jot\vskip #1\relax}}
  104. \def\eqalign{\null\,\vcenter\bgroup\openup1\jot \m@th \let\\=\@eqnacr
  105. \ialign\bgroup\strut
  106. \hfil$\displaystyle{##}$&$\displaystyle{{}##}$\hfil\crcr}
  107. \def\endeqalign{\crcr\egroup\egroup\,}
  108. % \cases
  109. \def\cases{\left\{\,\vcenter\bgroup\normalbaselines\m@th \let\\=\@eqnacr
  110.     \ialign\bgroup$##\hfil$&\quad##\hfil\crcr}
  111. \def\endcases{\crcr\egroup\egroup\right.}
  112. % Several formulas like \eqalignno (doesn't need the $$ $$)
  113. \def\eqalignno{\stepcounter{equation}\let\@currentlabel=\theequation
  114. \if@defeqnsw\global\@eqnswtrue\else\global\@eqnswfalse\fi
  115. \let\\=\@eqncr
  116. $$\displ@y \tabskip\@centering \halign to \displaywidth\bgroup
  117.   \global\@eqcnt\@ne\hfil
  118.   $\@lign\displaystyle{##}$\tabskip\z@skip&\global\@eqcnt\tw@
  119.   $\@lign\displaystyle{{}##}$\hfil\tabskip\@centering&
  120.   \llap{\@lign##}\tabskip\z@skip\crcr}
  121. \def\endeqalignno{\@@eqncr\egroup
  122.       \global\advance\c@equation\m@ne$$\global\@ignoretrue}
  123. % Here's the eqalignno* environment:
  124. \@namedef{eqalignno*}{\@defeqnswfalse\eqalignno}
  125. \@namedef{endeqalignno*}{\endeqalignno}
  126. % Two formulas like \eqalignno (doesn't need the $$ $$)
  127. \def\eqaligntwo{\stepcounter{equation}\let\@currentlabel=\theequation
  128. \if@defeqnsw\global\@eqnswtrue\else\global\@eqnswfalse\fi
  129. \let\\=\@eqncr
  130. $$\displ@y \tabskip\@centering \halign to \displaywidth\bgroup
  131.   \global\@eqcnt\m@ne\hfil
  132.   $\@lign\displaystyle{##}$\tabskip\z@skip&\global\@eqcnt\z@
  133.   $\@lign\displaystyle{{}##}$\hfil\qquad&\global\@eqcnt\@ne
  134.   \hfil$\@lign\displaystyle{##}$&\global\@eqcnt\tw@
  135.   $\@lign\displaystyle{{}##}$\hfil\tabskip\@centering&
  136.   \llap{\@lign##}\tabskip\z@skip\crcr}
  137. \def\endeqaligntwo{\@@eqncr\egroup
  138.       \global\advance\c@equation\m@ne$$\global\@ignoretrue}
  139. \@namedef{eqaligntwo*}{\@defeqnswfalse\eqaligntwo}
  140. \@namedef{endeqaligntwo*}{\endeqaligntwo}
  141. % subequations
  142. %%% File: subeqn.sty
  143. %%% The subequations environment %%%
  144. % Within the subequations environment, the only change is that
  145. % equations are labeled differently.  The number stays the same,
  146. % and lower case letters are appended.  For example, if after doing
  147. % three equations, numbered 1, 2, and 3, you start a subequations
  148. % environmment and do three more equations, they will be numbered
  149. % 4a, 4b, and 4c.  After you end the subequations environment, the
  150. % next equation will be numbered 5.
  151. % Both text and equations can be put inside the subequations environment.
  152. % If you make any improvements, I'd like to hear about them.
  153. % Stephen Gildea
  154. % MIT Earth Resources Lab
  155. % Cambridge, Mass. 02139
  156. % mit-erl!gildea
  157. % gildea@erl.mit.edu
  158. \newtoks\@stequation
  159. \def\subequations{\refstepcounter{equation}%
  160.   \edef\@savedequation{\the\c@equation}%
  161.   \@stequation=\expandafter{\theequation}%   %only want \theequation
  162.   \edef\@savedtheequation{\the\@stequation}% %expanded once
  163.   \edef\oldtheequation{\theequation}%
  164.   \setcounter{equation}{0}%
  165.   \def\theequation{\oldtheequation\alph{equation}}}
  166. \def\endsubequations{%
  167.   \setcounter{equation}{\@savedequation}%
  168.   \@stequation=\expandafter{\@savedtheequation}%
  169.   \edef\theequation{\the\@stequation}%
  170.   \global\@ignoretrue}
  171. % More from John Hobby
  172. % Fix Plain's \bigl, \Bigl, etc. macros so that they try to scale with
  173. % LaTeX size changes.  This uses the fact that \@setsize sets \ht\strutbox
  174. % to be 70% of the normal unstretched baselineskip.
  175. \def\big#1{{\hbox{$\left#1\vcenter to1.428\ht\strutbox{}\right.\n@space$}}}
  176. \def\Big#1{{\hbox{$\left#1\vcenter to2.142\ht\strutbox{}\right.\n@space$}}}
  177. \def\bigg#1{{\hbox{$\left#1\vcenter to2.857\ht\strutbox{}\right.\n@space$}}}
  178. \def\Bigg#1{{\hbox{$\left#1\vcenter to3.571\ht\strutbox{}\right.\n@space$}}}
  179. % More from Schaefer-Siebert / Kruljac
  180. %                              kruljac@ds0mpi11
  181. \def\@leqncr{{\ifnum0=`}\fi\@ifstar{\global\@eqpen\@M
  182.     \@yeqncr}{\global\@eqpen\interdisplaylinepenalty \@lyeqncr}}
  183. \def\@lyeqncr{\@ifnextchar [{\@lxeqncr}{\@lxeqncr[\z@]}}
  184. \def\@lxeqncr[#1]{\ifnum0=`{\fi}\@@leqncr
  185.    \noalign{\penalty\@eqpen\vskip\jot\vskip #1\relax}}
  186. \def\@@leqncr{\let\@tempa\relax\global\advance\@eqcnt by \@ne
  187.     \ifcase\@eqcnt \def\@tempa{& & & &}\or \def\@tempa{& & &}\or
  188.      \def\@tempa{& &}\or \def\@tempa{&}\else\fi
  189.      \@tempa \if@eqnsw\@leqnnum\stepcounter{equation}\fi
  190.      \if@defeqnsw\global\@eqnswtrue\else\global\@eqnswfalse\fi
  191.      \global\@eqcnt\z@\cr}
  192.  \def\@leqnnum{{\hspace{\fill}\hbox{\normalsize (\theequation)}}}
  193. \def\lequation#1{\bgroup#1$$ % $$ BRACE MATCHING HACK
  194. \refstepcounter{equation}}
  195. \def\endlequation{\eqno \@leqnnum % $$ BRACE MATCHING HACK
  196. $$\egroup\global\@ignoretrue}
  197. \def\leqnarray#1{\stepcounter{equation}\let\@currentlabel=\theequation
  198. \if@defeqnsw\global\@eqnswtrue\else\global\@eqnswfalse\fi
  199. \tabskip\@centering\let\\=\@leqncr
  200. \bgroup#1
  201. $$\halign to \displaywidth\bgroup\hfil\global\@eqcnt\z@
  202.   $\displaystyle\tabskip\z@{##}$&\global\@eqcnt\@ne
  203.   \hfil$\displaystyle{{}##{}}$\hfil
  204.   &\global\@eqcnt\tw@ $\displaystyle{##}$\hfil
  205.   \tabskip\@centering&\llap{##}\tabskip\z@\cr}
  206. \def\endleqnarray{\@@leqncr\egroup
  207.       \global\advance\c@equation\m@ne$$\egroup\global\@ignoretrue}
  208. % Here's the leqnarray* environment:
  209. \@namedef{leqnarray*}{\@defeqnswfalse\leqnarray}
  210. \@namedef{endleqnarray*}{\endleqnarray}
  211. \endinput
  212.